package edu.ucsd.ccdb.tagPopup.dataType;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JPanel;

import edu.ucsd.ccdb.tagPopup.util.SummaryPaneRefresher;
import edu.ucsd.irods.IRODSFileString;

public abstract class TagElementDisplay extends JPanel implements ActionListener {


	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	protected JButton deleleButton;
	
	// identifiers 
	protected Integer MPID; 
	protected IRODSFileString file;
	protected JPanel source;
	protected String username;
	
	public TagElementDisplay ( String username, JPanel source, Integer MPID, IRODSFileString file) {

		this.username = username;
		this.MPID = MPID;
		this.file = file;
		
		this.source = source ;
		ImageIcon image = new ImageIcon(  getClass().getResource("/images/delete.jpg") );
		this.deleleButton = new JButton(image);
		
		deleleButton.addActionListener( this );
		deleleButton.setContentAreaFilled(false);
		deleleButton.setBorderPainted(false);
		deleleButton.setToolTipText("Delete");
	}
	
	public void actionPerformed(ActionEvent e) {
		// delete this data 
		deleteData();
		
		// refresh
		SummaryPaneRefresher.doRefreshAction ( username, MPID, file, source);
	}
	
	public abstract void deleteData ();
	
}
